#pragma once

#include "Part.h"
#include "Common/ChatDefine.h"

class ChatPart : public Part
{
public:
	ChatPart();
	virtual ~ChatPart();

public:
	virtual bool		Init(Creature *pMaster, uint32_t partType, CharacterDBInfo* pCharacterDB = nullptr);
	virtual bool		UnInit();
	virtual bool		OnMsgHandle(uint32_t cmd, const char* data, uint32_t len);
	virtual void		OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen){}
	virtual void		OnTimer(uint32_t nTimerID){}

	virtual bool		SaveDB(CharacterDBInfo& characterDB);

	virtual void		Update(uint64_t tick){}

public: //消息回调接口
	void				HandleChatMsgReq(const char* data, uint32_t len);			//处理客户端发送聊天

private:
	uint32_t			GetChatWorldFreeTime();
	bool				InChannelCdTime(ProtoBuf::CHAT_TYPE type);

private:
	uint32_t			freeTimes;		//世界聊天每天免费发言次数
	uint32_t			updateTime;		//刷新时间
	uint32_t			worldCdTime;	//世界频道CD冷却
	uint32_t			guildCdTime;	//工会频道CD冷却
	uint32_t			teamCdTime;		//组队频道CD冷却
	uint32_t			sceneCdTime;	//当前频道CD冷却
	uint32_t			campCdTime;		//阵营频道CD冷却
};
